package com.ruoyi.manager.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manager.domain.TbeduClassinfo;
import com.ruoyi.manager.service.ITbeduClassinfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班级信息表Controller
 * 
 * @author 李红
 * @date 2021-09-16
 */
@Controller
@RequestMapping("/manager/classinfo")
public class TbeduClassinfoController extends BaseController
{
    private String prefix = "manager/classinfo";

    @Autowired
    private ITbeduClassinfoService tbeduClassinfoService;

    @RequiresPermissions("manager:classinfo:view")
    @GetMapping()
    public String classinfo()
    {
        return prefix + "/classinfo";
    }

    /**
     * 查询班级信息表列表
     */
    @RequiresPermissions("manager:classinfo:list")
    @PostMapping("/list")
    //@RequestMapping(value = "/list",method = RequestMethod.POST)
    @ResponseBody
    public TableDataInfo list(TbeduClassinfo tbeduClassinfo)
    {
        startPage();
        List<TbeduClassinfo> list = tbeduClassinfoService.selectTbeduClassinfoList(tbeduClassinfo);
        return getDataTable(list);
    }

    /**
     * 导出班级信息表列表
     */
    @RequiresPermissions("manager:classinfo:export")
    @Log(title = "班级信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbeduClassinfo tbeduClassinfo)
    {
        List<TbeduClassinfo> list = tbeduClassinfoService.selectTbeduClassinfoList(tbeduClassinfo);
        ExcelUtil<TbeduClassinfo> util = new ExcelUtil<TbeduClassinfo>(TbeduClassinfo.class);
        return util.exportExcel(list, "班级信息表数据");
    }

    /**
     * 新增班级信息表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存班级信息表
     */
    @RequiresPermissions("manager:classinfo:add")
    @Log(title = "班级信息表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbeduClassinfo tbeduClassinfo)
    {
        return toAjax(tbeduClassinfoService.insertTbeduClassinfo(tbeduClassinfo));
    }

    /**
     * 修改班级信息表
     */
    @GetMapping("/edit/{fId}")
    public String edit(@PathVariable("fId") Long fId, ModelMap mmap)
    {
        TbeduClassinfo tbeduClassinfo = tbeduClassinfoService.selectTbeduClassinfoByFId(fId);
        mmap.put("tbeduClassinfo", tbeduClassinfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存班级信息表
     */
    @RequiresPermissions("manager:classinfo:edit")
    @Log(title = "班级信息表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbeduClassinfo tbeduClassinfo)
    {
        return toAjax(tbeduClassinfoService.updateTbeduClassinfo(tbeduClassinfo));
    }

    /**
     * 删除班级信息表
     */
    @RequiresPermissions("manager:classinfo:remove")
    @Log(title = "班级信息表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbeduClassinfoService.deleteTbeduClassinfoByFIds(ids));
    }
}
